<template>
  <div class='left-box flex flex-space-between flex-column hide-scrollbar'>
    <div class="box-title">
      <CustomTitle title="安全队伍" :isAutoMargin="false" :isLine="true" fontSet="font1"></CustomTitle>
    </div>
    <div class="box-content flex flex-wrap hide-scrollbar">
      <div class="box-item flex" v-for="(item, index) in itemGroup" :key="index">
        <div class="item-icon flex flex-bcenter">
          <i class="iconfontShuzhi" :class="getIconClass(item.type)"></i>
        </div>
        <div class="item-content flex flex-column both-100">
          <div class="item-title">{{ item.title }}</div>
          <div class="item-content">
            <NumberCard v-model="item.value" :time="1" type="normal"></NumberCard>
          </div>

        </div>
      </div>
    </div>
    <!-- <List :listDataObject="data" :listIconConfig="teamIconList"></List> -->
  </div>
</template>

<script>
import { getSecurityTeam } from '../api'
import List from '@/components/Dashboard/List'
import NumberCard from '@/components/Dashboard/Number';
export default {
  components: {
    List,
    NumberCard
  },
  data () {
    return {
      data: {},
      itemGroup: [],
      // 安全队伍对应图标
      teamIconList: {
        '安全管理人员': 'anquangongchengshi',
        '安全责任人员': 'zhuanzhianquanguanliyuan',
        '值班人员': 'zhibanrenyuan',
        '安全分管领导': 'anquanfenguanlingdao',
        '安全主管领导': 'anquanzhuguanlingdao',
      },
      // 加载状态
      loading: true,
      fontStyle: {
        fontFamily: 'Oswald',
        fontWeight: '500',
        fontSize: '20px',
        color: '#30dcff'
      }
    };
  },
  computed: {},
  watch: {},
  methods: {    // 获取数据
    async getData (deptId) {
      try {
        const params = {
          deptId
        }
        const response = await getSecurityTeam(params)
        if (response.code === 200) {
          this.itemGroup = []
          this.initTeamList(response.data)
        }
      }
      catch (err) {
        console.log(err)
      }
    },
    initTeamList (data) {
      for (const key in data) {
        this.itemGroup.push({
          title: key,
          value: data[key],
          type: this.teamIconList[key]
        })
      }
    },
    getIconClass (type) {
      const inPreFix = 'icon-'
      const cleanedType = this.cleanInput(type)
      return cleanedType ? inPreFix + cleanedType : inPreFix + 'renyuan'
    },
    cleanInput (input) {
      if (typeof input === 'string') {
        return input.trim()
      }
      return undefined
    }
  },
}
</script>

<style lang='less' scoped>
.box-title {
  width: 100%;
}
.box-content {
  height: calc(100% - 40px);
  margin: 0 auto;
  gap: 15px;
  overflow: auto;
  flex-wrap: wrap;
  align-items: center;
  .box-item {
    width: 45%;
    .item-icon {
      width: 60px;
      height: 60px;
      background: url("@/assets/images/dashboard/box1.png") no-repeat;
      background-size: contain;
    }
    .item-content {
      flex: 1;
      .item-content {
        background: rgba(143, 171, 191, 0.1);
        padding: 5px;
        box-sizing: border-box;
      }
      .item-title {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #d9e7ff;
        position: relative;
        &::before {
          content: "";
          position: absolute;
          top: 10px;
          bottom: 0;
          width: 100%;
          height: 6px;
          background: rgba(143, 171, 191, 0.1);
        }
      }
    }
  }
}
</style>